/*
 * This file is part of Dorado 7.x (http://dorado7.bsdn.org).
 * 
 * Copyright (c) 2002-2012 BSTEK Corp. All rights reserved.
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * and BSDN commercial (http://www.bsdn.org/licenses) licenses.
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at http://www.bstek.com/contact.
 */

package com.bstek.dorado.data.provider.manager;

import com.bstek.dorado.data.config.definition.DataCreationContext;
import com.bstek.dorado.data.config.definition.DataProviderDefinition;
import com.bstek.dorado.data.config.definition.DataProviderDefinitionManager;
import com.bstek.dorado.data.provider.DataProvider;

/**
 * 默认的DataProvider管理类。
 * 
 * @author Benny Bao (mailto:benny.bao@bstek.com)
 * @since Mar 8 2007
 */
public class DefaultDataProviderManager implements DataProviderManager {
	private DataProviderDefinitionManager dataProviderDefinitionManager;

	/**
	 * 设置DataProvider配置声明管理器。
	 */
	public void setDataProviderDefinitionManager(
			DataProviderDefinitionManager dataProviderDefinitionManager) {
		this.dataProviderDefinitionManager = dataProviderDefinitionManager;
	}

	public DataProviderDefinitionManager getDataProviderDefinitionManager() {
		return dataProviderDefinitionManager;
	}

	public DataProvider getDataProvider(String name) throws Exception {
		DataProviderDefinition definition = dataProviderDefinitionManager
				.getDefinition(name);
		return (definition != null) ? (DataProvider) definition
				.create(new DataCreationContext()) : null;
	}

}
